﻿@{
    Layout = "~/Areas/admin/Views/Shared/_LayoutList.cshtml";
    ViewBag.Title = "Indirect";
}
@section HeaderContent{
    <link rel="stylesheet" href="/scripts/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="/scripts/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
    <script type="text/javascript">
        //查询数据
        function search() {
            var text = $(".keyword").val();
            document.location = "?keywords=" + text;
        }
        var setting = {
            view: {
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function (treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return false;
                    } else {
                        return true;
                    }
                }
            }
        };

        var zNodes = [@Html.Raw(ViewBag.directs)];

        var code;
        function showCode(str) {
            if (!code) code = $("#code");
            code.empty();
            code.append("<li>" + str + "</li>");
        }

        $(document).ready(function () {
            var t = $("#treeDemo");
            t = $.fn.zTree.init(t, setting, zNodes);
            demoIframe = $("#testIframe");
            demoIframe.bind("load", loadReady);
            var zTree = $.fn.zTree.getZTreeObj("tree");
            zTree.selectNode(zTree.getNodeByParam("id", '1'));
        });

        function ZheDie(flag) {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            treeObj.expandAll(flag);
        }
    </script>
}
<form id="form1" method="post" action="#">
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
        <a href="../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <a href="../ChainTree/TreeDirect"><span>直推树图</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>直推树图</span>
    </div>
    <!--/导航栏-->
    <!--工具栏-->
    <div id="floatHead" class="toolbar-wrap">
        <div class="toolbar">
            <div class="box-wrap">
                <a class="menu-btn"><i class="iconfont icon-more"></i></a><a class="menu-btn"><i class="iconfont icon-more"></i></a>
                <div class="l-list">
                    <ul class="icon-list">
                        <li><a href="javascript:;" onclick="ZheDie(true);"><i class="iconfont icon-open"></i><span>展开所有</span></a></li>
                        <li><a href="javascript:;" onclick="ZheDie(false);"><i class="iconfont icon-close"></i><span>折叠所有</span></a></li>
                    </ul>
                </div>
                <div class="r-list">
                    <input type="text" class="keyword" value="@ViewBag.Keywords" />
                    <a href="javascript:search();" id="lbtnSearch" class="btn-search"><i class="iconfont icon-search"></i></a>
                </div>
            </div>
        </div>
    </div>
    <!--/工具栏-->
    <!--列表-->
    <div class="table-container">
        <div>
            <ul id="treeDemo" class="ztree"></ul>
        </div>
    </div>
    <!--/列表-->
    <!--内容底部-->
    <div class="line20"></div>

    <!--/内容底部-->

</form>
